package myplaydog.qf.com.yimixianproject.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by guqiang on 2016/9/20.
 * User: guqiang
 * Date: 2016/9/27
 * Email:xxxx@163.com
 * Project: YiMiXianProject
 */
public abstract class MyBaseAdapter<T> extends BaseAdapter{
    private List<T> data;
    private LayoutInflater inflater;

    public MyBaseAdapter(Context context){
        this.data =new ArrayList<>();
        this.inflater =LayoutInflater.from(context);
    }
    public LayoutInflater getInflater(){
        return  inflater;
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public T getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public void addAll(List<T> dd){
        data.addAll(dd);
        notifyDataSetChanged();
    }
    public void  clear(){
        data.clear();
        notifyDataSetChanged();
    }
}
